<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="format-detection" content="telephone=no,email=no" />
		<title>修改密码</title>
		<link href="../css/mui.min.css" rel="stylesheet" />
		<link href="../css/style.css" rel="stylesheet" />
		<link href="../css/account.css" rel="stylesheet"/>

	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">修改密码</h1>
		</header>
		<div class="mui-content">
			<div id='login-form' class="mui-input-group change-password">
				<div class="mui-input-row">
					<label>用户账号</label>
					<input id='account' type="text" class="mui-input-clear mui-input" value="" disabled>
				</div>
				<div class="mui-input-row">
					<label>旧 &nbsp;密&nbsp; 码</label>
					<input id='password' type="text" class="mui-input-clear mui-input" placeholder="请输入旧密码">
				</div>
				<div class="mui-input-row mui-password">
					<label>新 &nbsp;密&nbsp; 码</label>
					<input id='newPassword' type="password" class="mui-input-password mui-input" placeholder="请输入新密码">
				</div>
				<div class="mui-input-row mui-password">
					<label>确认密码</label>
					<input id='newPasswordConfirm' type="password" class="mui-input-password mui-input" placeholder="请确认密码">
				</div>
			</div>
			<div class="mui-content-padded">
				<button id='changePassword' class="mui-btn mui-btn-block mui-btn-danger">提 交</button>
			</div>
		</div>
		<script src="../js/mui.min.js"></script>
		<script src="../js/app.js"></script>
		<script>
			mui.init({swipeBack: true});
			mui.plusReady(function() {
				document.getElementById('account').value=himall.getState().account;
				var oldPassword=document.getElementById('password'),
					newPassword=document.getElementById('newPassword'),
					newPasswordConfirm=document.getElementById('newPasswordConfirm');
				document.getElementById('changePassword').addEventListener('tap',function(){
					if(oldPassword.value.length < 6){
						plus.nativeUI.toast('旧密码最短为 6 个字符');
						return;
					}
					if(newPassword.value.length < 6){
						plus.nativeUI.toast('新密码最短为 6 个字符');
						return;
					}
					if (newPasswordConfirm.value != newPassword.value) {
						plus.nativeUI.toast('新密码两次输入不一致');
						return false;
					}
					var w=plus.nativeUI.showWaiting('',{padlock:true});
					mui.ajax(url+'UserCenter/ChangePassword',{
						data:JSON.stringify({
							oldPassword:oldPassword.value,
							password:newPassword.value,
							webToken:'rqlh',
						}),
						dataType:'json',
						contentType:'application/json',
						type:'post',
						timeout:10000,
						success:function(data){
							w.close();
							if(data.success){
								plus.nativeUI.toast(data.msg);
								setTimeout(function(){plus.webview.currentWebview().close()},1000);
							}else{
								plus.nativeUI.toast(data.msg);
							}
						},
						error:function(xhr,type,errorThrown){
							w.close();
							plus.nativeUI.toast('修改密码失败，请检查网络')
						}
					});
				});
			});
			
		</script>
	</body>

</html>